import React, { Component } from "react";
import PropTypes from "prop-types";
import R from "../../utils/ramda.js";

import GroupHeader from "./groupHeader";

function showFormerCompany(company) {
  if (!company.formerCompanyName && !company.formerPosition) {
    return "hidden";
  }
  return "";
}

function showEducationInfo(education) {
  if (!education.highestEdu && !education.formerPosition && !education.major) {
    return "hidden";
  }
  return "";
}
export default class Experience extends Component {
  constructor(props) {
    super(props);
  }
  render() {
    const formerCompanyinfo =
      R.isEmpty(this.props.formerCompanyinfo) ||
      R.isNil(this.props.formerCompanyinfo)
        ? {
            formerCompanyName: "",
            formerPosition: ""
          }
        : this.props.formerCompanyinfo;
    const educationalInfo =
      R.isEmpty(this.props.educationalInfo) ||
      R.isNil(this.props.educationalInfo)
        ? {
            highestEdu: "",
            graduateSchool: "",
            major: ""
          }
        : this.props.educationalInfo;
    return (
      <div className="growth-profile">
        <GroupHeader title="过往经历" color="red" />

        <div
          className={`growth-profile-group ${showFormerCompany(
            formerCompanyinfo
          )}`}
        >
          <div className="growth-profile-field">上家单位</div>
          <div className="growth-profile-value">
            {formerCompanyinfo.formerCompanyName +
              " " +
              formerCompanyinfo.formerPosition}
          </div>
        </div>
        <div
          className={`growth-profile-group ${showEducationInfo(
            educationalInfo
          )}`}
        >
          <div className="growth-profile-field">最高学历</div>
          <div className="growth-profile-value">
            {educationalInfo.highestEdu +
              " " +
              educationalInfo.graduateSchool +
              " " +
              educationalInfo.major}
          </div>
        </div>
      </div>
    );
  }
}

Experience.propTypes = {
  formerCompanyinfo: PropTypes.object,
  educationalInfo: PropTypes.object
};
